import App from './App.vue';
import router from './router';
import i18n from './i18n';
import '@/utilities/emitter';

import './tailwind.css';

const app = createApp(App);

const pinia = createPinia();
pinia.use(async ({ store }) => {
  const { ws } = await import('@/store/Plugins/WebSocketPlugin');
  store.$subscribe(() => {
    // Response store change
  });
  store.$onAction((action) => {
    // Response store actions
    if (`${action.store.$id}/${action.name}` === 'authentication/logout') {
      if (ws) ws.close();
    }
  });
});

app.use(pinia);
app.use(router);
app.use(i18n);

app.mount('#app');
